package com.jic.market.mapper;

import com.jic.market.orm.BaseMapper;
import com.jic.market.entity.PromotionLimitRuleEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PromotionLimitRuleEntityMapper extends BaseMapper<PromotionLimitRuleEntity> {

    int updateLimit(PromotionLimitRuleEntity limitRuleEntity);

    /**
     * 根据 促销id 和 商品id 查询
     * @param promotionId
     * @param limitRef
     * @return
     */
    PromotionLimitRuleEntity getEntityByPromotionIdAndMpId
            (@Param("promotionId") Long promotionId, @Param("limitRef") Long limitRef);

    /**
     * 根据 促销id 和 商品id 删除
     * @param promotionId
     * @param productId
     * @return
     */
    Integer deleteEntityByPromotionIdAndMpId
    (@Param("promotionId") Long promotionId, @Param("productId") Long productId);

    /**
     * 根据 促销id 查询List
     * @param promotionId
     * @param
     * @return
     */
    List<PromotionLimitRuleEntity> queryByPromotionId(@Param("promotionId") Long promotionId);

    PromotionLimitRuleEntity queryPromotionLimitRuleByEntity(PromotionLimitRuleEntity queryPromotionLimitRuleEntity);

    /**
     * 根据 促销id 和 商品id  和类型 删除
     * @param promotionId
     * @param productId
     * @return
     */
    Integer deleteByLimitTypeAndPidAndRef
    (@Param("promotionId") Long promotionId, @Param("limitRef") Long productId, @Param("limitType") Integer limitType);

    int insertBatch(@Param("items") List<PromotionLimitRuleEntity> items);
}